import { defineStore } from 'pinia'

export const useUserStore = defineStore({
  id: 'userInfo',
  state: () => ({
    userId: null,
    userName: '',
    phone: '',
    role: '',
    iconUrl: '',
    roles: ['admin'],
  }),
  actions: {
    SetInfo: function(data) {
      this.userId = data.userId;
      this.userName = data.userName;
      this.phone = data.phone;
      this.role = data.role;
      this.iconUrl = data.iconUrl;
    },
    GetInfo: async function() {
      return{
        userId:this.userId,
        userName:this.userName,
        phone:this.phone,
        role:this.role,
        iconUrl:this.iconUrl
      }
    },
    removeInfo: function() {
      this.userId = null;
      this.userName = '';
      this.phone = '';
      this.role = '';
      this.iconUrl = '';
    },
  }
})
